package com.project.util;

import java.util.Date;

import com.project.entity.ActualResults;
import com.project.entity.ProjectCheckRecord;
import com.project.entity.ProjectDistributeLog;
import com.project.entity.ProjectFee;
import com.project.entity.ProjectManagement;
import com.project.entity.ProjectSuperVisoryManagement;
import com.project.entity.User;
import com.project.mapper.ProjectSuperVisoryManagementMapper;
/**
 * 工具类，用于在新建项目信息时插入相关的收费记录，项目监督管理记录，验收记录并初始化。
 * 作者：甘雨
 */
public class ProjectManagementToProjectFee {
	
	public static ProjectFee autoCreateFee(ProjectManagement projectManagement){
		ProjectFee projectFee = new ProjectFee();
		projectFee.setProjectname(projectManagement.getProjectname());
		projectFee.setProjectnumber(projectManagement.getProjectnumber());
		projectFee.setProjectdirector(projectManagement.getProjectdirector());
		projectFee.setUndertakeunit(projectManagement.getMainundertakeunit());
//		projectFee.setWhethercharges("0");
		return projectFee;
	}
	
	public static ProjectCheckRecord autoCreateCheck(ProjectManagement projectManagement){
		ProjectCheckRecord projectCheckRecord = new ProjectCheckRecord();
		projectCheckRecord.setProjectname(projectManagement.getProjectname());
		projectCheckRecord.setProjectnumber(projectManagement.getProjectnumber());
		projectCheckRecord.setUndertakeunit(projectManagement.getMainundertakeunit());
		return projectCheckRecord;
	}
	
	public static ProjectSuperVisoryManagement autoCreateProjectSuperVisoryManagement(ProjectManagement projectManagement){
		ProjectSuperVisoryManagement projectSuperVisoryManagement = new ProjectSuperVisoryManagement();
		projectSuperVisoryManagement.setProjectname(projectManagement.getProjectname());
		projectSuperVisoryManagement.setProjectnumber(projectManagement.getProjectnumber());
		projectSuperVisoryManagement.setUndertakeunit(projectManagement.getMainundertakeunit());
		projectSuperVisoryManagement.setProjectdirector(projectManagement.getProjectdirector());
		projectSuperVisoryManagement.setProjectcontact(projectManagement.getContactman());
		projectSuperVisoryManagement.setFollowupperson(projectManagement.getFollowupperson());
		return projectSuperVisoryManagement;
	}
	
	public static User autoCreateUser(ProjectManagement projectManagement){
		User user = new User();
		user.setProjectnumber(projectManagement.getProjectnumber());
		//user.setUsername(projectManagement.getProjectdirector());
		user.setUsermailbox(projectManagement.getDirectoremail());
		user.setUserpassword("111111");                                                      //初始密码为   111111
		return user;
	}
	
	
	public static ProjectDistributeLog autoCreateProjectDistributeLog(ProjectManagement projectManagement){
		ProjectDistributeLog projectDistributeLog = new ProjectDistributeLog();
		projectDistributeLog.setProjectnumber(projectManagement.getProjectnumber());
		return projectDistributeLog;
	}
	
	
	public static ActualResults autoCreateActualResults(ProjectManagement projectManagement){
		ActualResults actualResults = new ActualResults();
		actualResults.setProjectnumber(projectManagement.getProjectnumber());
		actualResults.setProjectname(projectManagement.getProjectname());
		actualResults.setTimestamp(new Date());
		actualResults.setAuditmark("0");														//未审核；
		actualResults.setUndertakeunit(projectManagement.getMainundertakeunit());
//		actualResults.setAppearancedesignapplication(projectManagement.getAppearancedesignapplication());
//		actualResults.setInventpatentapplication(projectManagement.getInventpatentapplication());
//		actualResults.setInventpatentauthorization(projectManagement.getInventpatentauthorization());
//		actualResults.setUsenewapplication(projectManagement.getUsenewapplication());
//		actualResults.setUsenewauthorization(projectManagement.getUsenewauthorization());
//		actualResults.setAppearancedesignauthorization(projectManagement.getAppearancedesignauthorization());
//		actualResults.setForeignpatent(projectManagement.getForeignpatent());
//		actualResults.setNewtechnology(projectManagement.getNewtechnology());
//		actualResults.setNewproduct(projectManagement.getNewproduct());
//		actualResults.setNewmaterial(projectManagement.getNewmaterial());
//		actualResults.setNewequipment(projectManagement.getNewequipment());
//		actualResults.setComputersoftware(projectManagement.getComputersoftware());
//		actualResults.setPaper(projectManagement.getPaper());
//		actualResults.setTechnologystandard(projectManagement.getTechnologystandard());
//		actualResults.setNationalaward(projectManagement.getNationalaward());	
//		actualResults.setProvincialaward(projectManagement.getProvincialaward());
//		actualResults.setCityaward(projectManagement.getCityaward());
//		actualResults.setDoctor(projectManagement.getDoctor());
//		actualResults.setMaster(projectManagement.getMaster());
//		actualResults.setUndergraduate(projectManagement.getUndergraduate());
//		actualResults.setFundsavailable(projectManagement.getFundsavailable());
//		actualResults.setFundsinvestment(projectManagement.getFundsinvestment());
//		actualResults.setBenefitacquired(projectManagement.getBenefitacquired());
		
		if(projectManagement.getUsenewauthorization()==null){
			actualResults.setUsenewauthorization(0);
		}else{
			actualResults.setUsenewauthorization(projectManagement.getUsenewauthorization());
		}
		if(projectManagement.getAppearancedesignapplication()==null){
			actualResults.setAppearancedesignapplication(0);
		}else{
			actualResults.setAppearancedesignapplication(projectManagement.getAppearancedesignapplication());
		}		
		if(projectManagement.getInventpatentapplication()==null){
			actualResults.setInventpatentapplication(0);
		}else{
			actualResults.setInventpatentapplication(projectManagement.getInventpatentapplication());
		}		
		if(projectManagement.getInventpatentauthorization()==null){
			actualResults.setInventpatentauthorization(0);
		}else{
			actualResults.setInventpatentauthorization(projectManagement.getInventpatentauthorization());
		}		
		if(projectManagement.getUsenewapplication()==null){
			actualResults.setUsenewapplication(0);
		}else{
			actualResults.setUsenewapplication(projectManagement.getUsenewapplication());
		}		
		if(projectManagement.getUsenewapplication()==null){
			actualResults.setUsenewapplication(0);
		}else{
			actualResults.setUsenewapplication(projectManagement.getUsenewapplication());
		}		
		if(projectManagement.getAppearancedesignauthorization()==null){
			actualResults.setAppearancedesignauthorization(0);
		}else{
			actualResults.setAppearancedesignauthorization(projectManagement.getAppearancedesignauthorization());
		}		
		if(projectManagement.getForeignpatent()==null){
			actualResults.setForeignpatent(0);
		}else{
			actualResults.setForeignpatent(projectManagement.getForeignpatent());
		}		
		if(projectManagement.getNewtechnology()==null){
			actualResults.setNewtechnology(0);
		}else{
			actualResults.setNewtechnology(projectManagement.getNewtechnology());
		}		
		if(projectManagement.getNewproduct()==null){
			actualResults.setNewproduct(0);
		}else{
			actualResults.setNewproduct(projectManagement.getNewproduct());
		}		
		if(projectManagement.getNewmaterial()==null){
			actualResults.setNewmaterial(0);
		}else{
			actualResults.setNewmaterial(projectManagement.getNewmaterial());
		}		
		if(projectManagement.getNewequipment()==null){
			actualResults.setNewequipment(0);
		}else{
			actualResults.setNewequipment(projectManagement.getNewequipment());
		}		
		if(projectManagement.getComputersoftware()==null){
			actualResults.setComputersoftware(0);
		}else{
			actualResults.setComputersoftware(projectManagement.getComputersoftware());
		}		
		if(projectManagement.getPaper()==null){
			actualResults.setPaper(0);
		}else{
			actualResults.setPaper(projectManagement.getPaper());
		}		
		if(projectManagement.getTechnologystandard()==null){
			actualResults.setTechnologystandard(0);
		}else{
			actualResults.setTechnologystandard(projectManagement.getTechnologystandard());
		}		
		if(projectManagement.getNationalaward()==null){
			actualResults.setNationalaward(0);
		}else{
			actualResults.setNationalaward(projectManagement.getNationalaward());	
		}		
		if(projectManagement.getProvincialaward()==null){
			actualResults.setProvincialaward(0);
		}else{
			actualResults.setProvincialaward(projectManagement.getProvincialaward());
		}		
		if(projectManagement.getCityaward()==null){
			actualResults.setCityaward(0);
		}else{
			actualResults.setCityaward(projectManagement.getCityaward());
		}		
		if(projectManagement.getDoctor()==null){
			actualResults.setDoctor(0);
		}else{
			actualResults.setDoctor(projectManagement.getDoctor());
		}		
		if(projectManagement.getMaster()==null){
			actualResults.setMaster(0);
		}else{
			actualResults.setMaster(projectManagement.getMaster());
		}		
		if(projectManagement.getUndergraduate()==null){
			actualResults.setUndergraduate(0);
		}else{
			actualResults.setUndergraduate(projectManagement.getUndergraduate());
		}		
		if(projectManagement.getFundsavailable()==null){
			actualResults.setFundsavailable(0f);
		}else{
			actualResults.setFundsavailable(projectManagement.getFundsavailable());
		}		
		if(projectManagement.getFundsinvestment()==null){
			actualResults.setFundsinvestment(0f);
		}else{
			actualResults.setFundsinvestment(projectManagement.getFundsinvestment());
		}		
		if(projectManagement.getBenefitacquired()==null){
			actualResults.setBenefitacquired(0f);
		}else{
			actualResults.setBenefitacquired(projectManagement.getBenefitacquired());
		}
		return actualResults;
	}

}
